package dao;

import Jdbc.Employee;
import org.junit.Test;

import java.util.List;


import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Objects;

public class TestDao {
	@Test
	public void TestAdd() throws SQLException {
		Employee employee = new Employee(null, "jack", "销售", new Date(), 8000.0, 20);
		EmployeeDao employeeDao = new EmployeeDao();
		//System.out.println(employeeDao.add(employee));
		int len = employeeDao.add(employee);
		System.out.println("添加了" + len + "条记录");
	}

	@Test
	public void TestUpdate() throws SQLException {
		Employee employee = new Employee(8889, "jacj", "经理", new Date(), 5000.0, 30);
		EmployeeDao employeeDao = new EmployeeDao();
		int len = employeeDao.update(employee);
		System.out.println("添加了" + len + "条记录");
	}

	@Test
	public void TestgetById() throws Exception {
		Employee employee=new Employee();
		EmployeeDao employeeDao=new EmployeeDao();
		Employee emp=employeeDao.getById(8889);
		System.out.println(emp);
	}
	@Test
	public void testGetAll() throws Exception {
		EmployeeDao employeeDao = new EmployeeDao();
		List<Employee> employeeList = employeeDao.getAll();
		employeeList.forEach(System.out::println);
	}
	@Test
	public void testGetByEname() throws Exception {
		EmployeeDao employeeDao=new EmployeeDao();
		List<Employee> list= employeeDao.getByEname("A");
		list.forEach(System.out::println);
	}

}
